package com.notes.designpattern.chain2;

import com.google.common.collect.Maps;
import com.notes.designpattern.chain2.handler.BusinOneHandler;
import com.notes.designpattern.chain2.handler.BusinThreeHandler;
import com.notes.designpattern.chain2.handler.BusinTwoHandler;

import java.util.Map;

/**
 * @author
 * @Describe 功能描述
 * @date
 */
public class ChainTest {

    public static void main(String[] args) {
        BusinHandlerChain businHandlerChain = new BusinHandlerChain();
        businHandlerChain.addBusinHandler(new BusinOneHandler("BusinOneHandler"));
        businHandlerChain.addBusinHandler(new BusinTwoHandler("BusinTwoHandler"));
        businHandlerChain.addBusinHandler(new BusinThreeHandler("BusinThreeHandler"));

        Map<String, Object> businOneReq = Maps.newHashMap();
        businOneReq.put("businOneReq", "BusinOneHandler");
        Map<String, Object> process = businHandlerChain.process(businOneReq, businHandlerChain);

        if (String.valueOf(process.get("success")).equals("true")) {
            System.out.println("业务最终处理结果：成功");
        } else {
            System.out.println("业务最终处理结果：失败");
        }
    }
}
